package cn.yedong.system.service.impl;

import cn.yedong.basic.service.impl.BaseServiceImpl;
import cn.yedong.system.domain.DictionaryType;
import cn.yedong.system.mapper.DictionaryDetailMapper;
import cn.yedong.system.service.IDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictionaryTypeServiceImpl extends BaseServiceImpl<DictionaryType> implements IDictionaryTypeService {
   //注入
    @Autowired
    private DictionaryDetailMapper dictionaryDetailMapper;

    @Override
    public void del(Long id) {
        //删除类型之前，先根据类型id删除字典明细
        dictionaryDetailMapper.delByTypes_id(id);
        //根据类型id删除当前类型
        super.del(id);
    }

    @Override
    public void patchDel(List<Long> types_ids) {
        //批量删除类型之前，遍历选中行id集合,先根据类型id删除字典明细
//        for (Long id :ids) {
//            dictionaryDetailMapper.delByTypes_id(id);
//        }
        dictionaryDetailMapper.delByTypes_ids(types_ids);
        //批量删除当前类型
        super.patchDel(types_ids);
    }
}
